﻿<%--<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="edit.aspx.cs" Inherits="StoreWeb.system.news.edit"  ValidateRequest="false"  %>--%>
<%@ Page Language="C#"  ValidateRequest="false" AutoEventWireup="true" CodeBehind="edit.aspx.cs" Inherits="StoreWeb.system.news.edit" %>

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../../lib/html5.js"></script>
<script type="text/javascript" src="../../lib/respond.min.js"></script>
<script type="text/javascript" src="../../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />

    
    <link rel="stylesheet" href="../../ueditor/themes/default/css/ueditor.css" type="text/css">
    <script type="text/javascript" charset="utf-8" src="../../ueditor/editor_config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../ueditor/editor_all.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../ueditor/lang/zh-cn/zh-cn.js"></script>


    <!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>新建新闻</title>
</head>
<body>
    <div class="pd-20">
        <form runat="server" method="post" class="form form-horizontal" id="formmemberadd">
            <div class="row cl">
                <label class="form-label col-2"><span class="c-red">*</span>新闻标题：</label>
                <div class="formControls col-6">
                    <input type="text" class="input-text" value="" placeholder="" id="newstitile" name="newstitile" runat="server" datatype="*1-50" nullmsg="用户账户不能为空">
                </div>
                 <div class="col-4"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-2">查看对象：</label>
                <div class="formControls col-6">
                   <%-- <asp:DropDownList ID="ddluser" runat="server" Width="200" class="input-text" nullmsg="不能为空"></asp:DropDownList>--%>
                    <input name="selsectname" type="text" id="selsectname" class="input-text" style="width: 400px" placeholder="" readonly runat="server">
                    <input type="hidden" id="usernamehidden" name="usernamehidden" value="" runat="server">
                  <a class="btn btn-primary radius" href="javascript:;" onclick="admin_role_add('选择查看对象','adduser.aspx','600px','400px')"><i class="Hui-iconfont"></i> 选择查看对象</a>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-2">新闻内容：</label>
                <div class="formControls col-6">
                    <%--<input type="text" class="input-text" value="" placeholder="" id="newscontent" name="newscontent" runat="server">--%>
                     <script  id="editor" name="ueContent" type="text/plain"   ><%=congtenstr %> </script>
                </div>
            </div>
            <div class="row cl">
                <div class="col-10 col-offset-2">
                    <asp:HiddenField ID="hidid" runat="server" />
                    <asp:Button ID="btnok" runat="server" CssClass="btn btn-success radius" Text="确定" />
                </div>
            </div>
        </form>
    </div>
    <script type="text/javascript" src="../../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="../../lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="../../lib/Validform/5.3.2/Validform.min.js"></script>
    <script type="text/javascript" src="../../lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript" src="../../lib/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../../js/H-ui.js"></script>
    <script type="text/javascript" src="../../js/H-ui.admin.js"></script>
    <script>
        function admin_role_add(title, url, w, h) {
            //layer_show(title, url, w, h);
            var $input = $('#selsectname');
            var $hidden = $('#usernamehidden');
            var $checkbox;
            layer.open({
                type: 2,
                title: title,
                area: [w, h],
                content: url,
                btn: ['确定', '取消'],
                yes: function () {
                    var text = '';
                    var idText = '';
                    $.each($checkbox, function () {
                        var $this = $(this);
                        if ($this.is(':checked')) {
                            text += ($this.data('text') + ',');
                            idText += ($this.val() + ',')
                        }
                    });
                    if ('' == text)
                        layer.alert('请至少勾选一个查看对象');
                    else {
                        $input.val(text.substring(0, text.length - 1));
                        $hidden.val(idText.substring(0, idText.length - 1));
                        layer.closeAll();
                    }
                },
                success: function () {
                    $checkbox = layer.getChildFrame('#myTable input.checkbox');
                    var val = $hidden.val();
                    if ('' != val) {
                        var idArray = val.split(',');
                        for (var i in idArray) {
                            layer.getChildFrame('#' + idArray[i]).attr('checked', 'checked');
                        }
                    }
                }
            });
        }
        $(function () {
            $("#formmemberadd").Validform({
                tiptype: 2,
                btnSubmit: "#btnok",
                beforeSubmit: function (curform) {
                    //alert(UE.getEditor('editor').getContent());
                    $.post("../../ajax/news.aspx", { username: $("#selsectname").val(), userid: $("#usernamehidden").val(), newstitile: $("#newstitile").val(), newscontent: UE.getEditor('editor').getContent(), id: $("#hidid").val() },
                    function (data) {
                        if (data == 1) {
                            parent.layer.alert("添加成功", function () {
                                parent.location.reload();
                            });
                        } else if (data == 2) {
                            parent.layer.alert("修改成功", function () {
                                parent.location.reload();
                            });
                        } else {
                            parent.layer.msg("操作失败");
                        }
                    });
                    return false;
                }
            });
        });
    </script>
    <script type="text/javascript">

        //实例化编辑器
        //UE.getEditor('editor');

        var editor = new UE.ui.Editor({ initialFrameHeight: 10, initialFrameWidth: 620 });
        editor.render("editor");


        function createEditor() {
            enableBtn();
            UE.getEditor('editor')
        }
        function getAllHtml() {
            alert(UE.getEditor('editor').getAllHtml())
        }
        function getContent() {
            var arr = [];
            arr.push("使用editor.getContent()方法可以获得编辑器的内容");
            arr.push("内容为：");
            arr.push(UE.getEditor('editor').getContent());
            alert(arr.join("\n"));
        }
        function getPlainTxt() {
            var arr = [];
            arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
            arr.push("内容为：");
            arr.push(UE.getEditor('editor').getPlainTxt());
            alert(arr.join('\n'))
        }
        function setContent() {
            var arr = [];
            arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
            UE.getEditor('editor').setContent('欢迎使用ueditor');
            alert(arr.join("\n"));
        }
        function setDisabled() {
            UE.getEditor('editor').setDisabled('fullscreen');
            disableBtn("enable");
        }

        function setEnabled() {
            UE.getEditor('editor').setEnabled();
            enableBtn();
        }

        function getText() {
            //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
            var range = UE.getEditor('editor').selection.getRange();
            range.select();
            var txt = UE.getEditor('editor').selection.getText();
            alert(txt)
        }

        function getContentTxt() {
            var arr = [];
            arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
            arr.push("编辑器的纯文本内容为：");
            arr.push(UE.getEditor('editor').getContentTxt());
            alert(arr.join("\n"));
        }
        function hasContent() {
            var arr = [];
            arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
            arr.push("判断结果为：");
            arr.push(UE.getEditor('editor').hasContents());
            alert(arr.join("\n"));
        }
        function setFocus() {
            UE.getEditor('editor').focus();
        }
        function deleteEditor() {
            disableBtn();
            UE.getEditor('editor').destroy();
        }
        function disableBtn(str) {
            var div = document.getElementById('btns');
            var btns = domUtils.getElementsByTagName(div, "input");
            for (var i = 0, btn; btn = btns[i++];) {
                if (btn.id == str) {
                    domUtils.removeAttributes(btn, ["disabled"]);
                } else {
                    btn.setAttribute("disabled", "true");
                }
            }
        }
        function enableBtn() {
            var div = document.getElementById('btns');
            var btns = domUtils.getElementsByTagName(div, "input");
            for (var i = 0, btn; btn = btns[i++];) {
                domUtils.removeAttributes(btn, ["disabled"]);
            }
        }
</script>
</body>
</html>
